//
//  firstPageFirstSecctionCell_Ht.m
//  WZLProduct
//
//  Created by dllo on 16/3/19.
//  Copyright © 2016年 HaiTeng. All rights reserved.
//

#import "firstPageFirstSecctionCell_Ht.h"

@implementation firstPageFirstSecctionCell_Ht

- (void)setModel:(WHTFirstPageStoryModel *)model{
    if (model) {
        [self.cover_image sd_setImageWithURL:[NSURL URLWithString:model.index_cover] placeholderImage:[UIImage imageNamed:@"PlaceHolder_H_Ht"]];
        self.index_title.text = model.text;
        [self.avatar_s sd_setImageWithURL:[NSURL URLWithString:model.avatar_m] placeholderImage:[UIImage imageNamed:@"PlaceHolder_Other_Ht"]];
        self.name.text = [NSString stringWithFormat:@"   %@",model.name];
     
    }
}

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.contentView.layer.masksToBounds = YES;
        self.contentView.layer.cornerRadius = 4;
        self.contentView.backgroundColor = [UIColor whiteColor];
        
        self.cover_image = [[UIImageView alloc] init];
        [self.contentView addSubview:self.cover_image];
        
        self.index_title = [[UILabel alloc] init];
        [self.contentView addSubview:self.index_title];
        
        self.avatar_s = [[UIImageView alloc] init];
        [self.contentView addSubview:self.avatar_s];
        
        self.name = [[UILabel alloc] init];
        [self.contentView addSubview:self.name];
        
        self.cover_image.image = [UIImage imageNamed:@"TestPicture_HT.jpg"];
//        self.index_title.backgroundColor = [UIColor orangeColor];
        self.index_title.text = @"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
        self.index_title.numberOfLines = 0;
        self.index_title.font = FONT12;
        self.avatar_s.backgroundColor = [UIColor yellowColor];
        self.avatar_s.layer.masksToBounds = YES;
        self.avatar_s.layer.cornerRadius = 12.5;
//        self.name.backgroundColor = [UIColor cyanColor];
        self.name.text = @"xxxxxxxxxxxxxxxxxxx";
        self.name.font = FONT10;
        self.name.textColor = [UIColor lightGrayColor];
        
    }
    return self;
}


- (void)layoutSubviews{
    [super layoutSubviews];

    [self.cover_image mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.and.right.equalTo(self.contentView);
        make.height.equalTo(self.contentView.mas_height).multipliedBy(0.65);//设置宽度为self.view的一半，multipliedBy是倍数的意思，也就是，使宽度等于self.view宽度的0.5倍
    }];
    
    [self.index_title mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.cover_image.mas_bottom);
        make.left.equalTo(self.cover_image).with.offset(10);
        make.right.equalTo(self.cover_image).with.offset(-20);
        make.height.equalTo(self.contentView.mas_height).multipliedBy(0.2);
        
    }];
    
    [self.avatar_s mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.index_title.mas_bottom);
        make.left.equalTo(self.index_title);
        make.height.and.width.mas_equalTo(25);
    }];
   
    [self.name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.avatar_s.mas_right);
        make.height.equalTo(self.avatar_s);
        make.bottom.equalTo(self.avatar_s.mas_bottom);
        make.right.equalTo(self.contentView);
    }];
}



@end
